<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="120px">
      <el-form-item label="批次号" prop="batchNo">
        <el-input v-model="queryParams.batchNo" placeholder="请输入批次号" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="字段名称" prop="field">
        <el-input v-model="queryParams.field" placeholder="请输入字段名称" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" :data="fieldLogList">
      <el-table-column label="批次号" align="center" prop="batchNo" :show-overflow-tooltip="true" />
      <el-table-column label="变更日期" align="center" prop="busDate" :show-overflow-tooltip="true" />
      <el-table-column label="变更字段" align="center" prop="field" :show-overflow-tooltip="true" />
      <el-table-column label="变更前值" align="center" prop="oldValue" :show-overflow-tooltip="true" />
      <el-table-column label="变更后值" align="center" prop="newValue" :show-overflow-tooltip="true" />
      <el-table-column label="操作人" align="center" prop="operName" :show-overflow-tooltip="true" />
      <el-table-column label="操作人账号" align="center" prop="operAccNo" :show-overflow-tooltip="true" />
    </el-table>
    <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

  </div>
</template>

<script>
  import {
    listFieldLog,
    getFieldLog,
    delFieldLog,
    addFieldLog,
    updateFieldLog
  } from "@/api/bus_web/zzedu/fieldLog";

  export default {
    name: "FieldLog",
    data() {
      return {
        // 遮罩层
        loading: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 字段变更日志表格数据
        fieldLogList: [],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          relationId: null,
          relationType: null,
          field: null,
          fieldCode: null,
          newValue: null,
          oldValue: null,
        },
        // 表单参数
        form: {},
        // 表单校验
        rules: {

        }
      };
    },
    methods: {
      init(relationId, relationType) {
        this.queryParams.relationId = relationId
        this.queryParams.relationType = relationType
        this.handleQuery()
      },
      /** 查询字段变更日志列表 */
      getList() {
        this.loading = true;
        listFieldLog(this.queryParams).then(response => {
          this.fieldLogList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
    }
  };
</script>
